package com.ibeeking.gmc.global.g.rest.controller.v1.feign;

import com.ibeeking.found.common.entity.*;
import com.ibeeking.gmc.global.g.rest.service.IGlobalVariableService;
import com.ibeeking.gmc.global.g.rest.service.ITenantVariableService;
import com.ibeeking.nematos.constants.enums.OperateLogTypeEnum;
import com.ibeeking.nematos.log.annotation.Log;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @ClassName GlobalVariableFeignController
 * @Description 全局参数
 * @Author ibeeking
 * @Date 2020-10-22 10:34
 **/
@RestController
@RequestMapping("/g/variable/feign/v1")
public class GlobalVariableFeignController {

    @Resource
    private IGlobalVariableService globalVariableServiceImpl;

    @Resource
    private ITenantVariableService tenantVariableServiceImpl;

    /**
     * 通过param查询全局参数值
     *
     * @param query
     * @return
     */
    @PostMapping(value = "/queryGlobalVariable")
    public GlobalVariableDTO queryGlobalVariable(@RequestBody VariableQuery query) {
        return globalVariableServiceImpl.queryGlobalVariable(query);
    }

    /**
     * 通过param查询全局参数值
     *
     * @param query
     * @return
     */
    @PostMapping(value = "/queryTenantVariable")
    public TenantVariableDTO queryTenantVariable(@RequestBody VariableQuery query) {
        return tenantVariableServiceImpl.queryTenantVariable(query);
    }

    /**
     * 修改全局变量
     * @param param
     * @return
     */
    @Log(logType = OperateLogTypeEnum.MODIFY, describe = "修改全局变量")
    @PostMapping("/addAndModifyGlobalVariable")
    public Boolean addAndModifyGlobalVariable(@RequestBody GlobalVariableParam param) {
        return globalVariableServiceImpl.addAndModify(param);
    }
    /**
     * 修改租户全局变量
     * @param param
     * @return
     */
    @Log(logType = OperateLogTypeEnum.MODIFY, describe = "修改租户全局变量")
    @PostMapping("/addAndModifyTenantVariable")
    public Boolean addAndModifyTenantVariable(@RequestBody TenantVariableParam param) {
        return tenantVariableServiceImpl.addAndModify(param);
    }
}